﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace cnFederal
{
    public partial class SiteMaster : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                FaPosts.Load();
                CnfiAds.Load();
                Fvideos.Load(true);
                ASPxRoundPanel3.HeaderText = FaPosts.CustomTitle;
                if (string.IsNullOrWhiteSpace(FaPosts.CustomTitle))
                    ASPxRoundPanel3.Visible = false;
                else
                    ASPxRoundPanel3.Visible = true;

                //table_federalism


            }
            table_federalism.Visible = false;
            if (FaPosts.GetLastFederalismPosts(3) != null)
            {
                if (FaPosts.GetLastFederalismPosts(3).Count() > 0)
                    table_federalism.Visible = true;
            }
            table_LatinShortNews.Visible = false;
            if (FaPosts.GetLatinShortNewsByNymber(10) != null)
                if (FaPosts.GetLatinShortNewsByNymber(10).Count() > 0)
                    table_LatinShortNews.Visible = true;
         
            Nations.Load("Farsi");
            //LoadAd();
        }

     

        //private void LoadLastFedralism()
        //{
        //    if (this.LastFederalismPost != null)
        //    {
        //        table_federalism.Visible = true;
        //        this.LinkButton_federalism.Text = LastFederalismPost.Title;
        //        this.LinkButton_federalism.PostBackUrl = @"~/Fa-Forms/SelectedContent.aspx?Id=" + LastFederalismPost.Id;
        //        this.ImageBtnFederalism.ImageUrl = LastFederalismPost.ImageUrl;
        //        this.ImageBtnFederalism.PostBackUrl = @"~/Fa-Forms/SelectedContent.aspx?Id=" + LastFederalismPost.Id;

        //    }
        //    else
        //        table_federalism.Visible = false;
        //}
        //private void LoadActivity()
        //{
        //    if (this.LastActivity != null)
        //    {
        //        table_Activity.Visible = true;
        //        this.LinkButton_activity.Text = LastActivity.Title;
        //        this.LinkButton_activity.PostBackUrl = @"~/Fa-Forms/SelectedContent.aspx?Id=" + LastActivity.Id;
        //        this.ImageBtnActivity.ImageUrl = LastActivity.ImageUrl;
        //        this.ImageBtnActivity.PostBackUrl = @"~/Fa-Forms/SelectedContent.aspx?Id=" + LastActivity.Id;
        //    }
        //    else
        //        table_Activity.Visible = false;
        //}

        //private void LoadAd()
        //{
        //    if (this.CnfiAd != null)
        //    {
        //        TableAds.Visible = true;
        //        this.LinkButtonAds.Text = CnfiAd.Title;
        //        this.ImageButtonAds.ImageUrl = CnfiAd.ImageUrl;
        //    }
        //    else
        //        TableAds.Visible = false;
        //}
        public CnfiAd CnfiAd
        {
            get { return CnfiAds.GetTheLasAd(); }
        }
        public FaPost FaPost
        {
            get { return FaPosts.GetTheLasInterview(); }
        }
     
  


        public FaPost LastActivity
        {
            get { return FaPosts.GetTheLasActivity(); }
        }
        protected void LinkButtonInterview_Click(object sender, EventArgs e)
        {
            Response.Redirect(@"~/Fa-Forms/SelectedContent.aspx?Id="+FaPost.Id);
        }

        protected void LinkButtonAds_Click(object sender, EventArgs e)
        {
            if(CnfiAd != null)
            Response.Redirect(CnfiAd.AdsUrl);

        }

        protected void ImageButtonAds_Click(object sender, ImageClickEventArgs e)
        {
            if (CnfiAd != null)
                Response.Redirect(CnfiAd.AdsUrl);
        }

        protected void ImageButton3_Click(object sender, ImageClickEventArgs e)
        {
            Response.Redirect(@"https://www.facebook.com/pages/CNFI/424560464229717");
        }

        protected void ImageBtnActivity_Click(object sender, ImageClickEventArgs e)
        {

        }



      
    }
}
